package com.homedo.async.mysql.support.mapper.update;

import com.homedo.async.mysql.support.mapper.MapperI;
import io.vertx.sqlclient.SqlConnection;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;

/**
 * @author jgshun
 * @date 2020/3/17 10:30 AM
 */
public interface UpdateMapperI<T, ID> extends MapperI<T, ID> {

    Mono<Long> updateByIdSelective(T entity);

    Mono<Long> updateByIdsSelective(Iterable<? extends T> entities);

    Mono<Long> updateByIdsSelective(Publisher<? extends T> entityStream);

    Mono<Long> updateById(T entity);

    Mono<Long> updateByIds(Iterable<? extends T> entities);

    Mono<Long> updateByIds(Publisher<? extends T> entityStream);


    //=== 传入 Connection 是为了统一获得事务能力

    Mono<Long> updateByIdSelective(T entity, SqlConnection connection);

    Mono<Long> updateByIdsSelective(Iterable<? extends T> entities, SqlConnection connection);

    Mono<Long> updateByIdsSelective(Publisher<? extends T> entityStream, SqlConnection connection);

    Mono<Long> updateById(T entity, SqlConnection connection);

    Mono<Long> updateByIds(Iterable<? extends T> entities, SqlConnection connection);

    Mono<Long> updateByIds(Publisher<? extends T> entityStream, SqlConnection connection);

}
